
function MySlide(setting){

//	var slide = new MySlide({
//		imgs : $(".main .row2 .left .slide .imgs"),
//		btns : $(".main .row2 .left .slide .btns"),
//		texts : null,
//		wid	:	304,
//		ind	:	0,
//		auto :	false,
//		autoTime	:	3000,
//		inv	:	null,
//		ty	:	"img",
//		btnL:	null,
//		btnR:	null,
//		hasNum	:	false,
//		path:	"left",
//		showSize:	1
//	});

	this.setting = {
		imgs : null,
		btns : null,
		texts : null,
		wid	:	0,
		ind	:	0,
		auto :	false,
		autoTime	:	3000,
		inv	:	null,
		ty	:	"img",
		btnL:	null,
		btnR:	null,
		hasNum	:	false,
		path:	"left",
		showSize : 1
		
	}
	
	for(var att in setting){
		this.setting[att] = setting[att];
		
	}
	
}

MySlide.prototype.init = function(){
	
	if(this.setting.btns){
		this.createBtns();
	}
	if(this.setting.btnR){
		this.btnClick();
	}
	if(this.setting.texts){
		this.changText();
	}
	
};

MySlide.prototype.createBtns = function(){
	var This = this;
	var str = "";
	if(this.setting.hasNum){
		for(var i=0;i<this.setting.imgs.find(this.setting.ty).length;i++){
			str += "<span>"+(i+1)+"</span>";
		}
	}else{
		for(var i=0;i<this.setting.imgs.find(this.setting.ty).length;i++){
			str += "<span></span>";
		}
	}
	
	this.setting.btns.html(str);
	this.setting.btns.find("span").mouseover(function(){
		This.setting.ind = $(this).index();
		This.changeSlide();
	}).eq(0).addClass("cur");
	
};

MySlide.prototype.changeSlide = function(){
	if(this.setting.auto){
		this.autoPlay();
	}
	
	if(this.setting.path==="left"){
		this.setting.imgs.stop(false,false).animate({left:-this.setting.wid*this.setting.ind});
	}else{
		this.setting.imgs.stop(false,false).animate({top:-this.setting.wid*this.setting.ind});
	}
	
	if(this.setting.btns){
		this.setting.btns.find("span").removeClass("cur").eq(this.setting.ind).addClass("cur");
	}
	
	if(this.setting.texts){
		this.changText();
	}
};

MySlide.prototype.autoPlay = function(){
	var This = this;
	clearInterval(this.setting.inv);
	this.setting.inv = setInterval(function(){
		if(This.setting.ind>=This.setting.imgs.find(This.setting.ty).length-This.setting.showSize){
			This.setting.ind = 0;
		}else{
			This.setting.ind++;
		}
		This.changeSlide();
	},this.setting.autoTime);
	
};

MySlide.prototype.btnClick = function(){
	var This = this;
	this.setting.btnR.click(function(){
		if(This.setting.ind>=This.setting.imgs.find(This.setting.ty).length-This.setting.showSize){
			This.setting.ind = 0;
		}else{
			This.setting.ind++;
		}
		This.changeSlide();
		return false;
	});
	this.setting.btnL.click(function(){
		if(This.setting.ind<=0){
			This.setting.ind = This.setting.imgs.find(This.setting.ty).length-This.setting.showSize;
		}else{
			This.setting.ind--;
		}
		This.changeSlide();
		return false;
	});
}

MySlide.prototype.changText = function(){
	this.setting.texts.hide().eq(this.setting.ind).show();
}
